<html>
<head></head>
<body>
<div class="row">
    <div class="col-sm-12">
        <div class="animated fadeIn">
            <div class="col-sm-2">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>组织机构管理 <small>机构列表</small></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div id="orgDeptTree" class="ztree"></div>
                    </div>
                </div>
            </div>
            <div class="col-sm-10">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>用户管理 <small>用户列表</small></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal" id="queryForm">
                            <input type="hidden" name="deptId"/>
                            <input type="hidden" name="orgId"/>
                            <input type="hidden" name="postId"/>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-1" for="userName">用户名:</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" id="userName" name="userName">
                                    </div>
                                    <label class="control-label col-sm-2" for="phone">手机号码:</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" id="phone" name="phone">
                                    </div>
                                    <label class="control-label col-sm-1" for="status">状态:</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="status" id="status">
                                            <#list userStatus as u>
                                            <option value="${u.getCode()}">${u.getName()}</option>
                                        </#list>
                                        </select>
                                    </div>
                                    <div class="col-sm-2">
                                        <button type="button" id="searchFormSubmitBtn" class="btn btn-primary">查询</button>
                                        <button type="button" id="searchFormResetBtn" class="btn btn-primary">重置</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="btn-group-sm" id="userTb" role="group">
                            <@shiro.hasPermission name="/upms/user/create">
                            <button id="addBtn" type="button" class="btn btn-primary btn-sm dropdown-toggle" onclick="User.createUser()"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增</button>
                        </@shiro.hasPermission>
                        <@shiro.hasPermission name="/upms/user/updateStatus">
                        <button id="batchDisabledBtn" type="button"  class="btn btn-primary btn-sm dropdown-toggle" onclick="User.setSatus(1)"><span class="fa fa-lock"></span>批量冻结</button>
                        <button id="batchEnabledBtn" type="button"  class="btn btn-primary btn-sm dropdown-toggle" onclick="User.setSatus(0)"><span class="fa fa-unlock-alt"></span>批量解冻</button>
                        </@shiro.hasPermission>
                        <button id="delBtn" type="button"  class="btn btn-primary btn-sm dropdown-toggle" onclick="User.deleteUser()"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除</button>
                        </div>
                    <table id="userGrid"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<@shiro.hasPermission name="/upms/user/getRolesOfUser">
<input id="setRoleUser" type="hidden"/>
</@shiro.hasPermission>
<@shiro.hasPermission name="/upms/user/edit">
<input id="updateUserPassword" type="hidden"/>
</@shiro.hasPermission>
<script src="${ctx}/public/js/business/Resource.js"></script>
<script src="${ctx}/public/js/business/Organization.js"></script>
<script src="${ctx}/public/js/business/Role.js"></script>
<script src="${ctx}/public/js/business/User.js"></script>

<script>
    $(function () {
        var userGrid = User.initGrid('#userGrid');
        var orgTree = Organization.initTree("#orgDeptTree");
        orgTree.setting.callback.onClick = function (event, treeId, treeNode) {
            var ids = treeNode.id.split("-");

            var formData = FormUtils.getFormObj('#searchForm');
            //1组织2部门3岗位
            var type = parseInt(ids[0]);
            //对应id
            var id = ids[1];

            if (type === 1) {
                //根据组织id查找
                formData.orgId = id;
            } else if (type === 2) {
                //根据部门id查找
                formData.deptId = id;
            }else if (type === 3) {
                //根据岗位id查找
                formData.postId = id;
            }
            userGrid.bootstrapTable("refresh",{query:formData});
        }

        orgTree.setting.callback.onAsyncSuccess = function (event, treeId, treeNode,nodes) {
            var node = orgTree.getNodeByParam("id", (nodes[0].id));
            orgTree.expandNode(node, true, false, false);
        }
    })
</script>
</body>
</html>

